package com.whj.service;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whj.domain.entity.Article;
import com.whj.mapper.ArticleMapper;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ViewCountService {

    @Autowired
    private ArticleMapper articleMapper;

    @RabbitListener(queues = "myqueue")
    public void updateViewCountFail(Article article) {
        UpdateWrapper<Article> queryWrapper = new UpdateWrapper<>();
        queryWrapper.eq("id", article.getId());
        queryWrapper.set("view_count", article.getViewCount());
        articleMapper.update(null, queryWrapper);

    }
}
